﻿using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace WebSite.ViewModels.Fields
{
    public class LinkField : IField
    {
        public string Name { get; private set; }
        public object Value { get; private set; }

        private readonly string m_ActionName;
        private readonly string m_ControllerName;
        private readonly object m_RouteValues;

        public LinkField(string caption, string name, object value, string actionName, string controllerName, object routeValues)
        {
            Caption = caption;
            Value = value;
            Name = name;
            m_RouteValues = routeValues;
            m_ControllerName = controllerName;
            m_ActionName = actionName;
        }

        public string Caption { get; private set; }

        public IHtmlString Render(HtmlHelper htmlHelper)
        {
            return htmlHelper.ActionLink(Value.ToString(), m_ActionName, m_ControllerName, m_RouteValues, null);
        }

        public bool IsOneRow
        {
            get { return false; }
        }

        public bool IsEmpty { get { return false; } }
    }
}